package cn.maxhou.sl2.config;

import cn.maxhou.sl1.entity.SysRole;
import cn.maxhou.sl1.entity.SysUser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//定义配置类
@Configuration
public class JavaConfig {
    //定义bean对象
    @Bean
    //也可以通过注解的name属性修改bean名称
    //@Bean(name="user1")
    public SysUser user(){
        SysUser user = new SysUser();
        user.setRealName("张三");
        user.setAccount("zhangsan");
        user.setPassword("123456");
        user.setSex(1);
        //返回对象会被注册道Spring容器中
        return user;
    }

    //注册"管理员"角色bean对象
    @Bean
    public SysRole adminRole(){
        SysRole role = new SysRole();
        role.setId(1);
        role.setRoleName("管理员");
        role.setCode("ADMIN");
        return role;
    }
    //注册"店长"角色bean对象
    @Bean
    public SysRole managerRole(){
        SysRole role = new SysRole();
        role.setId(2);
        role.setRoleName("店长");
        role.setCode("MANAGER");
        return role;
    }
}
